import {
    baseUrl
} from './env'
import axios from "axios";
axios.interceptors.request.use(function(config) {
     
        //  loadinginstace = Loading.service({ fullscreen: true })
        // console.log(config)
       config.headers.token =  localStorage.getItem('token')
        // console.log(config)
        if(config.url.indexOf('/apps')>-1){
            return config;
        }
        // debugger
        
        if(!localStorage.getItem('appKey')){
            return false;
        }
        config.headers.appkey =  localStorage.getItem('appKey')
        return config
    }, error => {
        ///loadinginstace.close()
        //Message.error({
        //    message: '加载超时'
        // })
        return Promise.reject(error)
    })
    // http响应拦截器
axios.interceptors.response.use(data => { // 响应成功关闭loading
    ///loadinginstace.close()
    // console.log(data.data)
    return data.data
}, error => {
    //loadinginstace.close()
    //Message.error({
    //      message: '加载失败'
    // })
    // conso/le.log('ssssss')
    return Promise.reject(error)
})

export const get = (url, config) => {
    return axios.get(baseUrl + url, config)
}
export const post = (url, data, config) => {
    return axios.post(baseUrl + url, data, config);
}
export default {
    get,
    post
}